#pragma once

#include <WinSock2.h>
#include <string>

using std::string;

class InetSocketAddress
{
private:
	// Stores ip and port
	sockaddr_in inetSockAddress;
	const InetSocketAddress& operator= (const InetSocketAddress& rhs);
	void initializeInetSocketAddress(const char *ip, int port);
public:
	InetSocketAddress(const char *ip, int port);
	InetSocketAddress(const string& ip, int port);
	InetSocketAddress(const InetSocketAddress& rhs);

	static InetSocketAddress getByNameAndPort(const string& hostName, const string& port);
    static InetSocketAddress getByNameAndPort(const string& hostName, int port);

	/** 
	 * Returns the size of the sockaddr struct
	 */
	inline int size() const {
		return sizeof(::sockaddr);
	}

	/**
	 * Returns the InetSocketAddress casted to sockaddr*
	 */
	inline operator const sockaddr* const () const
	{
		return (sockaddr*) (&inetSockAddress);
	}

	virtual ~InetSocketAddress(void);
};
